package org.qq.tv.web.app;
import org.qq.tv.web.mapper.pojo.task.UpTaskDate;
import org.qq.tv.web.service.UpDateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/")
public class AppRoot {
    @Autowired
    private UpDateService sw;

    @GetMapping
    public String getById() {


        if (sw.getSqlcont() == 0 && sw.getNetcont() == 0) {
            // this.addWeb();
            this.update();
            return "任务开始";
        }

        String taskCont = "<p>" + sw.sqlTasktyep + "</p>" + "<p>" + sw.netTasktyep + "</p>";
        return "<p>任务已经开始</p>" + taskCont;
    }

    private void update() {
        UpTaskDate date = new UpTaskDate();
        date.setTaskTyep(UpTaskDate.upDate);
        sw.submitSql(date);
    }

    @PostMapping
    public void pu() {

    }

    private void addWeb() {
        UpTaskDate date = new UpTaskDate();
        date.setTaskTyep(UpTaskDate.addweb);
        date.getTableWeb().setId(1);
        date.getTableWeb().setName("四虎");
        date.getTableHostWeb().setPath("www.x5d6a.controller");
        date.getTableHostWeb().setM3u8("scdn.pw6j118p.controller");
        sw.submitSql(date);
    }
}
